package com.qfmy.web.mapper;

import com.qfmy.web.entity.login.LoginUser;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
/**
 * @author: 廖志伟
 * @date: 2024-11-28
 * @description: 登录用户Mapper接口
 */
@Mapper
@SuppressWarnings("all")
public interface LoginUserMapper {

    /**
     * 根据用户名查询用户信息
     * @param userName
     * @return
     */
    @Select("select id ,username , password,phone ,user_pic,create_time,update_time" +
            " from login_user where username = #{username}")
    public LoginUser selectByUserName(String userName);
    /**
     * 插入用户信息
     * @param loginUser
     */
    @Insert("insert into login_user (username,password,phone,create_time,update_time)" + "values (#{username},#{password},#{phone},#{createTime},#{updateTime})")
    void insertUser(LoginUser loginUser);

    /**
     * 根据id查询用户信息
     * @param id
     * @return
     */
    @Select("select id ,username , password,phone ,user_pic,create_time,update_time from login_user where id = #{id}")
    LoginUser selectById(Long id);

    /**
     * 根据id更新用户信息
     * @param loginUser
     * @param id
     */
    @Update("update login_user set password=#{loginUser.password},phone=#{loginUser.phone} where id=#{id}")
    void updateById(LoginUser loginUser, Long id);


}
